/**
 * 
 */
package com.user.query.utils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

/**
 * 时间工具
 * @author chuzz
 *
 */
public class DateUtils {
	public static String getCurrentDate(String format) {
		Calendar c = Calendar.getInstance();
		DateFormat df = new SimpleDateFormat(format);
		df.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
		return df.format(c.getTime());
	}
	
	public static Date getLastDay(Date date){
		Calendar calendar = Calendar.getInstance();		
		calendar.setTime(date);		
		calendar.add(Calendar.DAY_OF_MONTH, -1);		
		date = calendar.getTime();		
		return date;
	}
	public static String getLastDay(Date date,String pattern){
		Calendar calendar = Calendar.getInstance();		
		calendar.setTime(date);		
		calendar.add(Calendar.DAY_OF_MONTH, -1);		
		date = calendar.getTime();
		SimpleDateFormat format = new SimpleDateFormat(pattern);
		return format.format(date);
	}
}
